package com.jr.controller;

import com.jr.entry.User;
import com.jr.service.UserService;
import com.jr.util.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController /*替换@RestController=@Controller + @ResponseBody*/
@RequestMapping("/Us/")
public class UserController {

    @Autowired
    private UserService userMapperService;
    @Autowired
    private ResultObject result;


    @RequestMapping("findAll")
    public User findAll(User user){
        return userMapperService.login(user);
    }

    @RequestMapping("insert")
    public ResultObject insert(User user){
        if (user.getUsername()!="" && user.getPassword()!="") {
            result.setResult(userMapperService.register(user));
        }else {
            result.setResult("");
        }
        return result;
    }


}
